package cn.congine.wizarpos.mall.service.impl;

/**
 * 模板消息类型
 * 
 * @author xudongdong
 *         2016年3月1日 下午5:31:12
 */
public enum MsgType {
	
	// 模板消息类型(短信充值通知SMS_CHARGE,短信余额通知SMS_BALANCE,收款通知PAYMENT,退款通知REFUND,下单提醒ORDER_SUBMIT,订单取消ORDER_CANCEL)
	SmsCharge("SMS_CHARGE", 0), Sms_Balance("SMS_BALANCE", 1), Pament("PAYMENT", 2), 
	Refund("REFUND", 3), OrderSubmit("ORDER_SUBMIT", 4), OrderCancel("ORDER_CANCEL", 5);
	
	private String name;
	private int index;

	private MsgType(String name, int index) {
		this.name = name;
		this.index = index;
	}
	
	public static boolean contains(String name) {
		for (MsgType ct : MsgType.values()) {
			if (ct.getName().equals(name)) {
				return true;
			}
		}
		return false;
	}

	public static String getName(Integer index) {
		if (null == index) {
			return "";
		}
		for (MsgType ct : MsgType.values()) {
			if (ct.getIndex() == index) {
				return ct.getName();
			}
		}
		return String.valueOf(index);
	}

	public static int getIndex(String name) {
		for (MsgType ct : MsgType.values()) {
			if (ct.getName().equals(name)) {
				return ct.getIndex();
			}
		}
		return -1;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}
}
